﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace SOEN341_SCHEDULER_PHASE1
{
    static class GlobalVariablesClass
    {
        public static int LocationMainX;
        public static int LocationMainY;

        public static int originalStudentPageWidth;

        public static string newAccountName = null;

        public static List<Course>[] GeneratedCourses;

        public static List<Course> courseSelected;

        public static string directory_Current = Directory.GetCurrentDirectory();
        public static string directory_Data = directory_Current + "\\data\\";
        public static string file_StudentRegistered = directory_Data + "registeredStudents.osl";
        public static string file_ErrorFile = directory_Data + "errorLog.txt";

        //public static EducationalProgram EDU_ENGR;
        public static EducationalProgram EDU_SOEN;
        public static EducationalProgram EDU_CIVI;
        public static EducationalProgram EDU_COEN;
        public static EducationalProgram EDU_ELEC;
        public static EducationalProgram EDU_MECH;

        public static List<EducationalProgram> list_EDU_AllPrograms;

        public static void InitAllPrograms()
        {
            //EDU_ENGR = new EducationalProgram("ENGINEERING CORE", null);
            EDU_SOEN = new EducationalProgram("SOFTWARE ENGINEERING", null);
            EDU_CIVI = new EducationalProgram("CIVIL ENGINEERING", null);
            EDU_COEN = new EducationalProgram("COMPUTER ENGINEERING", null);
            EDU_ELEC = new EducationalProgram("ELECTRICAL ENGINEERING", null);
            EDU_MECH = new EducationalProgram("MECHANICAL ENGINEERING", null);

            list_EDU_AllPrograms = new List<EducationalProgram>();
            list_EDU_AllPrograms.Add(EDU_SOEN);
            list_EDU_AllPrograms.Add(EDU_CIVI);
            list_EDU_AllPrograms.Add(EDU_COEN);
            list_EDU_AllPrograms.Add(EDU_ELEC);
            list_EDU_AllPrograms.Add(EDU_MECH);
            //list_EDU_AllPrograms.Add(EDU_ENGR);

            ProgramsInitialization.InitCIVI(EDU_CIVI);
            ProgramsInitialization.InitCOEN(EDU_COEN);
            ProgramsInitialization.InitELEC(EDU_ELEC);
            ProgramsInitialization.InitMECH(EDU_MECH);
            ProgramsInitialization.InitSOEN(EDU_SOEN);
            //ProgramsInitialization.InitENGR(EDU_ENGR);

        }

        public static ui_form_Login ui_main_form_login;

        public static List<Student> list_RegisteredStudents;

        public static Student session_loggedInStudent;

        public enum ErrorCodes
        {
            Course_ClassFull,
            Course_NoPrerequistes,
            Student_CourseAlreadyTaken
        }

        public static void LogError(string msg)
        {
            StreamWriter sw = null;
            char[] dashToAdd;
            try
            {
                dashToAdd = new char[DateTime.Now.ToString().Length];
                for (int i = 0; i < dashToAdd.Length; i++)
                {
                    dashToAdd[i] = '-';
                }

                sw = new StreamWriter(file_ErrorFile, true);
                sw.WriteLine(new string(dashToAdd));
                sw.WriteLine(DateTime.Now.ToString());
                sw.WriteLine(new string(dashToAdd));
                sw.WriteLine(msg);
                sw.Close();
            }
            catch (Exception)
            {
                //error could not be logged
                if (sw != null)
                {
                    sw.Close();
                }
                
            }
        }
    }
}
